﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace Apply
{
    class Book : INotifyPropertyChanged
    {
        private string title;
        private string publisher;
        private string isBn;
        public Book()
        {
        }
        public String Title
        {
            get
            {
                return title;
            }
            set
            {
                title = value;
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("Title"));
            }
        }
        public String Publisher
        {
            get
            {
                return publisher;
            }
            set
            {
                publisher = value;
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("Publisher"));
            }
        }
        public String IsBn
        {
            get
            {
                return isBn;
            }
            set
            {
                isBn = value;
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("IsBn"));
            }
        }
        private readonly List<string> authors = new List<string>();

        public string[] Authors
        {
            get { return authors.ToArray(); }
        }
        public Book(string title, string publisher, string isBn, params string[] authors)
        {
            this.Title = title;
            this.Publisher = publisher;
            this.IsBn = isBn;
            this.authors.AddRange(authors);
        }

        public override string ToString()
        {
            return Title;
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
